﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class orderComplete : System.Web.UI.Page
{
    private static int pageCurrent = 1;
    private static int pagerowsSize = 3;
    private static int total = 0;
    private static int pageCount = 0;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            orderBind(pageCurrent, pagerowsSize);
        }
    }

    public void orderBind(int pcount, int psize)
    {
        using (SOAWebService.Service1 ser = new SOAWebService.Service1())
        {
            int? b = 0;
            int[] xx= ser.getTotal();
            total = xx[0];
            pageCount = xx[1];
            GridView1.DataSource = ser.getpagesplitOrder(pcount, psize, ref b);
            GridView1.DataBind();
        }
    }
    protected void lnbtnfirst_Click(object sender, EventArgs e)
    {
        pageCurrent = 1;
        orderBind(pageCurrent, pagerowsSize);
    }
    protected void lnbtnprevious_Click(object sender, EventArgs e)
    {
        if (pageCurrent == 1)
        {
            pageCurrent = 1;
        }
        else
        {
            pageCurrent--;
        }
        orderBind(pageCurrent, pagerowsSize);
    }
    protected void lnbtnnext_Click(object sender, EventArgs e)
    {
        if (pageCurrent == pageCount)
        {
            pageCurrent = pageCount;
        }
        else
        {
            pageCurrent++;
        }
        orderBind(pageCurrent, pagerowsSize);
    }
    protected void lnbtnlast_Click(object sender, EventArgs e)
    {
        pageCurrent = pageCount;
        orderBind(pageCurrent, pagerowsSize);
    }
    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        SOAWebService.Service1 ser = new SOAWebService.Service1();
        string orderId = e.CommandArgument.ToString();
        if (e.CommandName.ToString() == "agree")
        {

            ser.updateOrderStateById(orderId, "agree");
            Response.Write("<script>alert('同意！');location.href='orderComplete.aspx';</script>");
        }
        else if (e.CommandName.ToString() == "refuse")
        {
            ser.updateOrderStateById(orderId, "refuse");
            Response.Write("<script>alert('不同意！');location.href='orderComplete.aspx';</script>");
        }
    }
    public string  changeState(int i)
    {
        string state = null;
        switch (i)
        {
            case 1: state="预定";break;
                    
            case 2: state= "终止"; break;

            case 3: state= "完成"; break;

            default: state = "xx"; break;
        }
        return state;
    }
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            e.Row.Attributes.Add("onmouseover", "curr=this.style.backgroundColor;this.style.backgroundColor='blue'");
            e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=curr");
            ImageButton img = (ImageButton)e.Row.FindControl("imgbtndel");
        }
    }
}
